//
//  GMGuardCheckingTableViewCell.m
//  GuardMan
//
//  Created by steven on 2017/3/26.
//  Copyright © 2017年 steven. All rights reserved.
//

#import "GMGuardCheckingTableViewCell.h"

@implementation GMGuardCheckingTableViewCell

- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self setupMainView];
    }
    return self;
}

- (void)setupMainView {
    [self addSubview:self.guardImageView];
    [self addSubview:self.hintLabel];
    
    // guard image view
    [self.guardImageView autoAlignAxisToSuperviewAxis:ALAxisHorizontal];
    [self.guardImageView autoPinEdgeToSuperviewEdge:ALEdgeLeading withInset:38];
    [self.guardImageView autoSetDimensionsToSize:CGSizeMake(32, 52)];
    
    // hint label
    [self.hintLabel autoPinEdge:ALEdgeLeading toEdge:ALEdgeTrailing ofView:self.guardImageView withOffset:50];
    [self.hintLabel autoPinEdge:ALEdgeTrailing toEdge:ALEdgeTrailing ofView:self withOffset:42];
    [self.hintLabel autoAlignAxisToSuperviewAxis:ALAxisHorizontal];
    [self.hintLabel sizeToFit];
}

#pragma mark - getter for guard image view
- (UIImageView *)guardImageView {
    if (!_guardImageView) {
        _guardImageView = [[UIImageView alloc] init];
        _guardImageView.image = [UIImage imageNamed:@"guard-icon"];
    }
    
    return _guardImageView;
}

#pragma mark - getter for hint label
- (UILabel *)hintLabel {
    if (!_hintLabel) {
        _hintLabel = [[UILabel alloc] init];
        _hintLabel.textColor = HINT_COLOR;
        _hintLabel.font = [UIFont systemFontOfSize:10];
        _hintLabel.numberOfLines = 2;
    }
    
    return _hintLabel;
}

@end
